package com.ry.aop.myaop;


import com.ry.aop.myaop.advicechain.*;
import java.util.ArrayList;
import java.util.List;

/**

 前置通知 Before
 执行除法操作
 后置通知 After
 异常通知 AfterThrowing
 Exception in thread "main" java.lang.ArithmeticException: / by zero


 前置通知 Before
 执行除法操作
 后置通知 After
 返回通知 AfterReturning

 */
public class Run {

    public static void main(String[] args) throws Throwable {

        UserService userService1 = new UserService();
//        userService1.insert();
//
//        System.out.println("=====================");
//
//        UserService userService2 = new ProxyFactory().getProxy(userService1);
//        userService2.insert();

//        List<BaseAdvice> adviceList = new ArrayList<>();
//
//        adviceList.add(new ThrowAdvice());
//        adviceList.add(new ReturnAdvice());
//        adviceList.add(new AfterAdvice());
//        adviceList.add(new BeforeAdvice());
//
//        Chain chain = new Chain(adviceList);
//
//        chain.proceed();

        UserService userService3 = new ProxyFactory2().getProxy(userService1);
        userService3.insert("小明");

    }

}
